import Cookies from 'js-cookie'
import { Base64 } from 'js-base64';

const TokenKey = 'x-token'

export function getToken() {
  return Cookies.get(TokenKey);
}

export function setToken(token) {
  Cookies.set(TokenKey, token);
  let sub=eval('(' + Base64.decode(token.split(".")[1]) + ')');
  console.log(sub);
  Cookies.set("NICKNAME",sub.nickName);
}

export function removeToken() {
  return Cookies.remove(TokenKey);
}

export function getNickName(){
  return Cookies.get("NICKNAME");
}